//
//  LGFollowKeywordView.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2024/7/8.
//  关键词

#import "LGFollowKeywordView.h"

@interface LGFollowKeywordView()

/**   */
@property (nonatomic , strong)UILabel *contentLabel;
/**   */
@property (nonatomic , strong)UIButton *deleteBtn;

@end

@implementation LGFollowKeywordView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        [self addBorder:@"#CCCCCC" lineWidth:1 cornerRidus:5];
        [self addSubview:self.contentLabel];
        [self addSubview:self.deleteBtn];
        [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(viewPix(10));
            make.right.equalTo(self).offset(-viewPix(30));
            make.centerY.equalTo(self);
        }];
        [self.deleteBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.right.bottom.equalTo(self);
            make.width.equalTo(@(viewPix(30)));
        }];
    }
    return self;
}

-(void)setContent:(NSString *)content{
    _content = content;
    self.contentLabel.text = content;
}

-(void)deleteBtnAction{
    if (self.delegate && [self.delegate respondsToSelector:@selector(deleteKeywordItem:)]) {
        [self.delegate deleteKeywordItem:self.tag-1000];
    }
}

-(UILabel *)contentLabel{
    if(!_contentLabel){
        _contentLabel = [UILabel lableWithText:@"" colorString:@"#5E8EF5" textFont:LGFont(15) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _contentLabel;
}

-(UIButton *)deleteBtn{
    if(!_deleteBtn){
        _deleteBtn = [UIButton buttonWithImage:@"closeGray16" selectImage:@"closeGray16"];
        [_deleteBtn addTarget:self action:@selector(deleteBtnAction) forControlEvents:UIControlEventTouchUpInside];
    }
    return _deleteBtn;
}

@end
